#ifndef CONTROLWIDGET_H
#define CONTROLWIDGET_H
#include<QtGui>
#include<phonon>
class TrackPlayer;
class LyricPanel;
class PlayListWidget;
class LyricSetting;
class Lyrics;
class LyricSearchWidget;
namespace Ui {
class ControlWidget;
}

//enum LyricMode {RollingLyric=0,DesktopLyric};
class ControlWidget:public QWidget
{
    Q_OBJECT
public:
    //    friend class TrackPlayer;
    friend class MainWindow;
    explicit ControlWidget(QWidget* parent=0);
    void setPlayer(Phonon::AudioOutput *output,Phonon::MediaObject *object);
private:
    //    void creatWidgets();
    void initWgt();
    void creatActions();
    void creatConnections();

    Ui::ControlWidget *ui;

    TrackPlayer* player;
    PlayListWidget* playListWgt;
    LyricPanel* lyricPanel;
    LyricSetting* lyricSettings;
    LyricSearchWidget* lrcSearchWgt;
    QSystemTrayIcon *trayIcon;
    QAction *showMainWindowAct;
    QAction *nextTrackAct;
    QAction *prevTrackAct;
    QAction *playOrPauseAct;
    QAction *quitAct;
    QAction *lyricSettingAct;
    QAction *desktopLyricAct;
    QAction *searchLyricAct;
    QAction *lockDesktopLyricAct;
    QMenu *trayMenu;
    QMenu *lyricMenu;
    QAction *listRepeatAct;
    QAction *ordinalPlayAct;
    QAction *trackRepeatAct;
    QAction *randomPlayAct;
    QList<QAction*> modeActList;
    QMenu *playModeMenu;
    bool lyricPanelLocked;
    bool haveLyricPanel;
    bool lyricReady;
    Lyrics *lrc;
    bool haveNext;          //a flag for auto playing next track
signals:
    void showList(bool);
    void showLyricWgt(bool);
    void addTrackRequest(const QString& dir, const QStringList &fileNames);
private slots:
    void onShowListToggled(bool);
    void onShowLyricWgtToggled(bool);
    void onPlayBtnToggled(bool);
    void onLyricSettingClosed();
    void onSearchLyricTriggered();
    void onListCloseRequested();
    void onTick(qint64);
    void onDesktopLyricToggled(bool);
    void quit();
    void showAll();
    void onDownFinished(QString);
    void onAboutToFinish();
    void onTrayIconActived( QSystemTrayIcon::ActivationReason reason);
    void onPlayModeChanged();
public slots:
    void onStateChanged(Phonon::State newState,Phonon::State oldState);
    void onLyricSetTriggered();
protected:
    void closeEvent(QCloseEvent *);
};
#endif // CONTROLWIDGET_H
